package com.ruyuan.eshop.common.mananger.impl;

import com.ruyuan.eshop.common.mananger.OrderOperateClientManager;
import com.ruyuan.eshop.common.enums.OrderPermission;
import com.ruyuan.eshop.common.domain.entity.OrderDO;
import com.ruyuan.eshop.common.domain.entity.OrderLogDO;
import com.ruyuan.eshop.common.domain.entity.OrderOutStatusDO;
import com.ruyuan.eshop.common.domain.entity.TransactionRecordDO;
import com.ruyuan.eshop.common.enums.OrderOutStatusEnum;
import com.ruyuan.eshop.common.enums.OrderOutTypeEnum;
import com.ruyuan.eshop.common.enums.OrderServiceStatusEnum;
import com.ruyuan.eshop.common.domain.vo.CancelVO;
import com.ruyuan.eshop.common.service.trade.order.*;
import com.ruyuan.eshop.common.service.trade.GoodsSnapshotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单操作SDK
 *
 * @author pwd
 * @version 1.0
 */
@Service
public class OrderOperateClientManagerDefaultImpl implements OrderOperateClientManager {

    @Autowired
    private OrderOperateService orderOperateService;

    @Autowired
    private GoodsSnapshotService goodsSnapshotService;

    @Autowired
    private OrderOutStatusService orderOutStatusService;

    @Autowired
    private TransactionRecordService transactionRecordService;

    @Autowired
    private OrderPayService orderPayService;

    @Autowired
    private OrderLogService orderLogService;

    @Override
    public void updateItemJson(String itemsJson, String orderSn) {

        orderOperateService.updateItemJson(itemsJson, orderSn);
    }

    @Override
    public void addGoodsSnapshot(OrderDO orderDO) {
        goodsSnapshotService.add(orderDO);
    }

    @Override
    public void editOrderShopName(Long shopId, String shopName) {
        orderOperateService.editOrderShopName(shopId, shopName);
    }

    @Override
    public void cancel(CancelVO cancelVO, OrderPermission permission) {
        orderOperateService.cancel(cancelVO, permission);
    }

    @Override
    public void updateServiceStatus(String orderSn, OrderServiceStatusEnum serviceStatus) {
        orderOperateService.updateServiceStatus(orderSn, serviceStatus);
    }

    @Override
    public void editOutStatus(String orderSn, OrderOutTypeEnum typeEnum, OrderOutStatusEnum statusEnum) {
        orderOutStatusService.edit(orderSn, typeEnum, statusEnum);
    }

    @Override
    public TransactionRecordDO addTransactionRecord(TransactionRecordDO transactionRecordDO) {
        return transactionRecordService.add(transactionRecordDO);
    }

    @Override
    public void paySuccess(String tradeType, String subSn, String returnTradeNo, Double payPrice) {

        orderPayService.paySuccess(tradeType, subSn, returnTradeNo, payPrice);
    }

    @Override
    public void add(OrderOutStatusDO orderOutStatusDO) {
        orderOutStatusService.add(orderOutStatusDO);
    }

    @Override
    public void addOrderLog(OrderLogDO logDO) {
        orderLogService.add(logDO);
    }
}
